// Fill out your copyright notice in the Description page of Project Settings.


#include "Character/KnightCharacter.h"
#include "PaperFlipbookComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"

AKnightCharacter::AKnightCharacter()
{
	//设置精灵角色
	GetSprite()->SetCastShadow(true);//启用阴影
	GetSprite()->SetRelativeLocation(FVector(-3.0f, 0.0f, -2.0f));
	//pawn中使用控制器选择，因为Character本身就继承自pawn类
	bUseControllerRotationYaw = false;
	//生成相机摇臂
	SpringArmComponent = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
	SpringArmComponent->SetupAttachment(RootComponent);
	SpringArmComponent->TargetArmLength = 400.0f;
	SpringArmComponent->SetRelativeLocation(FVector(0.0f, 0.0f, 50.0f));
	SpringArmComponent->bInheritYaw=false;
	//相机摇臂旋转 z轴对应Yaw x轴对应Pitch y轴对应Roll
	SpringArmComponent->SetRelativeRotation(FRotator(0.0f, -90.0f, -0.0f));
	SpringArmComponent->bEnableCameraLag = true;//相机是否有滞后效果
	//生成相机
	CameraComponent= CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
	CameraComponent->SetupAttachment(SpringArmComponent);
	CameraComponent->bUsePawnControlRotation = false;
	//设置运动组件
	GetCharacterMovement()->bOrientRotationToMovement=true;//随着移动选择
	GetCharacterMovement()->RotationRate = FRotator(0.0f, 10000.0f, 0.0f);//设置选择速率
}
